﻿using Ec.NETCoreFramework.Common.Core;
using System;
using System.Collections.Generic;
using System.Text;

namespace Ec.NETCoreFramework.Common.Plug.Core
{
    
    public class AppConfig
    {
        /// <summary>
        /// automapper 需要通过反射读取的程序集,通过|隔开
        /// </summary>
        public List<JobConfig> Jobs { get; set; }
        public MQConfig MQConf { get; set; }
        /// <summary>
        /// 请求时签名的密钥
        /// </summary>
        public RequestAppSecret ReqAppSecret { get; set; }
        /// <summary>
        /// 根据dll 名称获取对应的处理任务
        /// </summary>
        /// <param name="dllName"></param>
        /// <returns></returns>
        public JobConfig GetJob(string dllName)
        {
            return this.Jobs.Find((s) => s.DllName.Contains(dllName)) ?? new JobConfig();
        }
        /// <summary>
        /// 软件版本
        /// </summary>
        public string SoftwareVersion { get; set; }
    }
    /// <summary>
    /// 任务配置
    /// </summary>
    public class JobConfig
    {
        /// <summary>
        /// dll文件名
        /// </summary>
        public string DllName { get; set; }
        /// <summary>
        /// 消费端
        /// </summary>
        public List<ConsumeConfig> Consumes { get; set; }
        /// <summary>
        /// 定时计划时间间隔
        /// </summary>
        public string CronSchedule { get; set; }
        /// <summary>
        /// 描述
        /// </summary>
        public string Desc { get; set; }
        /// <summary>
        /// 虚拟机名称
        /// </summary>
        public string VirtualHost { get; set; }
    }
    /// <summary>
    /// 消费端配置
    /// </summary>
    [ProtoBuf.ProtoContract]
    public class ConsumeConfig
    {
        /// <summary>
        /// 唯一标识
        /// </summary>
        [ProtoBuf.ProtoMember(1)]
        public string UnionId { get; set; }
        /// <summary>
        /// 队列名称
        /// </summary>
        [ProtoBuf.ProtoMember(2)]
        public string MQName { get; set; }
        /// <summary>
        /// vast接口域名
        /// </summary>
        [ProtoBuf.ProtoMember(3)]
        public string Domain { get; set; }
        /// <summary>
        /// 企业微信接口域名
        /// </summary>
        [ProtoBuf.ProtoMember(4)]
        public string WechatDomain { get; set; }
        /// <summary>
        /// fkid
        /// </summary>
        [ProtoBuf.ProtoMember(5)]
        public int FKId { get; set; }
        /// <summary>
        /// dbid
        /// </summary>
        [ProtoBuf.ProtoMember(6)]
        public int DBId { get; set; }
        /// <summary>
        /// appid
        /// </summary>
        [ProtoBuf.ProtoMember(7)]
        public string AppId { get; set; }
        /// <summary>
        /// secret
        /// </summary>
        [ProtoBuf.ProtoMember(8)]
        public string Secret { get; set; }
        /// <summary>
        /// 任务触发时，可能发送多个消息给队列
        /// </summary>
        [ProtoBuf.ProtoMember(9)]
        public string[] ActionName { get; set; }
    }
    /// <summary>
    /// mq配置
    /// </summary>
    public class MQConfig
    {
        /// <summary>
        /// 服务器
        /// </summary>
        public string Server { get; set; }
        /// <summary>
        /// 用户名
        /// </summary>
        public string UserName { get; set; }
        /// <summary>
        /// 密码
        /// </summary>
        public string Pwd { get; set; }
    }

}
